package tmhm.shemes;


import java.awt.Point;
import java.util.ArrayList;

import tmhm.components.*;
import tmhm.gui.GuiLabel;
import tmhm.gui.GuiLine;
import tmhm.gui.GuiScheme;


public class Bus1 {
    
    private static BUS IBUS1, IBUS2, IBUS3;
    private static BUS ABUS, DBUS;
    private static BUS NOTRDBUS, NOTWRBUS, NOTFCBUS;
    private static TSB TSBMOST1_2, TSBMOST2_1, TSBMDRout1, TSBeMAR, TSBeMDR, TSBrdCPU, TSBwrCPU, TSBDWout3, TSB1;
    private static TSB TSBMOST1_3, TSBMOST3_2; // dodato
    private static IntToInt IBUS1low;
    private static MP MX1;
    private static AND AND1, AND2;
    private static OR OR1;
    private static REG MAR, MDR, DWH, DWL;
    private static NOT NOT1, NOT2, NOT3, NOT4;
    private static BoolsToInt DW, DWHint, DWLint;
    //brojaci koliko ima prikacenih listenera na magistralu
    private static int abusi = 0, dbusi = 0, ibus1i = 0, ibus2i = 0, ibus3i = 0, rdbusi = 0, wrbusi = 0, fcbusi = 0;
    private static GuiScheme gui;
    
    public static GuiScheme getGui() {
        return gui;
    }
    
    public static void init() {

        // neka bude da ih je 16 nakaceno na magistralu
        IBUS1 = new BUS(16, 1, "IBUS1");
        IBUS1.getOut(0).setNumOfLines(16);
        IBUS2 = new BUS(16, 1, "IBUS2");
        IBUS2.getOut(0).setNumOfLines(16);
        IBUS3 = new BUS(24, 1, "IBUS3");
        IBUS3.getOut(0).setNumOfLines(16);
        
        ABUS = new BUS(16, 1, "ABUS");
        ABUS.getOut(0).setNumOfLines(16);
        
        DBUS = new BUS(16, 1, "DBUS");
        DBUS.getOut(0).setNumOfLines(8);
        
        NOTRDBUS = new BUS(8, 1, "NOTRDBUS");
        NOTRDBUS.getOut(0).setIsBool();
        NOTWRBUS = new BUS(8, 1, "NOTWRBUS");
        NOTWRBUS.getOut(0).setIsBool();
        NOTFCBUS = new BUS(8, 1, "NOTFCBUS");
        NOTFCBUS.getOut(0).setIsBool();
        
        TSBMOST1_2 = new TSB();
        TSBMOST1_2.getOut(0).setNumOfLines(16);
        TSBMOST1_2.setIsMostTSB(true);
        
        TSBMOST2_1 = new TSB();
        TSBMOST2_1.getOut(0).setNumOfLines(16);
        TSBMOST2_1.setIsMostTSB(true);
        
        TSBMOST1_3 = new TSB();
        TSBMOST1_3.getOut(0).setNumOfLines(16);
        TSBMOST1_3.setIsMostTSB(true);
        
        TSBMOST3_2 = new TSB();
        TSBMOST3_2.getOut(0).setNumOfLines(16);
        TSBMOST3_2.setIsMostTSB(true);
        
        TSBMDRout1 = new TSB();
        TSBMDRout1.getOut(0).setNumOfLines(8);
        
        TSBeMAR = new TSB();
        TSBeMAR.getOut(0).setNumOfLines(16);
        
        TSBeMDR = new TSB();
        TSBeMDR.getOut(0).setNumOfLines(8);
        
        TSBrdCPU = new TSB();
        TSBrdCPU.getOut(0).setNumOfLines(1);
        TSBrdCPU.getOut(0).setIsBool();
        
        TSBwrCPU = new TSB();
        TSBwrCPU.getOut(0).setNumOfLines(1);
        TSBwrCPU.getOut(0).setIsBool();
        
        TSBDWout3 = new TSB();
        TSBDWout3.getOut(0).setNumOfLines(16);
        
        IBUS1low = new IntToInt(16, 8, false, false);//sa 16 na 8 linija za MDR i DW

        MX1 = new MP(2);
        MX1.getOut(0).setIsInt();
        MX1.getOut(0).setNumOfLines(8);
        
        AND1 = new AND();
        AND2 = new AND();
        OR1 = new OR();
        
        MAR = new REG(1, "MAR");
        MAR.getOut(0).setIsInt();
        MAR.getOut(0).setNumOfLines(16);
        
        MDR = new REG(1, "MDR");
        MDR.getOut(0).setIsInt();
        MDR.getOut(0).setNumOfLines(8);
        
        DWH = new REG(8, "DWH");
        DWL = new REG(8, "DWL");
        
        TSB1 = new TSB();
        TSB1.getOut(0).setNumOfLines(1);
        TSB1.getOut(0).setIsBool();
        NOT1 = new NOT();
        
        NOT2 = new NOT();
        NOT3 = new NOT();
        NOT4 = new NOT();
        
        DW = new BoolsToInt(16, 16);
        DWHint = new BoolsToInt(8, 8);
        DWLint = new BoolsToInt(8, 8);
    }
    
    public static void connect() {
        
        TSBMOST1_2.setInputPin(0, IBUS1.getOut(0));
        TSBMOST1_2.setCtrl(Oper1.MOST1_2());
        Bus1.addOnIBUS2(TSBMOST1_2.getOut(0));
        
        TSBMOST2_1.setInputPin(0, IBUS2.getOut(0));
        TSBMOST2_1.setCtrl(Oper1.MOST2_1());
        Bus1.addOnIBUS1(TSBMOST2_1.getOut(0));
        
        TSBMOST1_3.setInputPin(0, IBUS1.getOut(0));
        TSBMOST1_3.setCtrl(Oper1.MOST1_3());
        Bus1.addOnIBUS3(TSBMOST1_3.getOut(0));
        
        TSBMOST3_2.setInputPin(0, IBUS3.getOut(0));
        TSBMOST3_2.setCtrl(Oper1.MOST3_2());
        Bus1.addOnIBUS2(TSBMOST3_2.getOut(0));
        
        IBUS1low.setInputPin(0, IBUS1.getOut(0));
        
        MX1.setInputPin(0, DBUS.getOut(0));
        MX1.setInputPin(1, IBUS3.getOut(0));
        MX1.setCtrl(0, Oper1.mxMDR());
        
        TSB1.setInputPin(0, Bus1.NOTFCBUS());
        NOT1.setInputPin(0, TSB1.getOut(0));
        
        AND1.setInputPin(0, Oper1.rdCPU());
        AND1.setInputPin(1, NOT1.getOut(0));
        
        OR1.setInputPin(0, Oper1.ldMDR());
        OR1.setInputPin(1, AND1.getOut(0));
        
        MDR.setInputPin(0, MX1.getOut(0));
        MDR.setPinLd(OR1.getOut(0));
        
        TSBMDRout1.setInputPin(0, MDR.getOut(0));
        TSBMDRout1.setCtrl(Oper1.MDRout1());
        Bus1.addOnIBUS1(TSBMDRout1.getOut(0));
        
        TSBeMDR.setInputPin(0, MDR.getOut(0));
        TSBeMDR.setCtrl(Oper1.eMDR());
        Bus1.addOnDBUS(TSBeMDR.getOut(0));
        
        MAR.setInputPin(0, IBUS2.getOut(0));
        MAR.setPinLd(Oper1.ldMAR());
        MAR.setPinInc(Oper1.incMAR());
        
        TSBeMAR.setInputPin(0, MAR.getOut(0));
        TSBeMAR.setCtrl(Oper1.eMAR());
        Bus1.addOnABUS(TSBeMAR.getOut(0));
        
        TSBrdCPU.setInputPin(0, new Pin(true));
        TSBrdCPU.setCtrl(Oper1.rdCPU());
        NOT2.setInputPin(0, TSBrdCPU.getOut(0));
        Bus1.addOnNOTRDBUS(NOT2.getOut(0));
        
        TSBwrCPU.setInputPin(0, new Pin(true));
        TSBwrCPU.setCtrl(Oper1.wrCPU());
        NOT3.setInputPin(0, TSBwrCPU.getOut(0));
        Bus1.addOnNOTWRBUS(NOT3.getOut(0));
        
        NOT4.setInputPin(0, Oper1.eMAR());
        //AND2.setInputPin(0, Oper1.hreq());
        AND2.setInputPin(0, new Pin(false));
        AND2.setInputPin(1, NOT4.getOut(0));
        
        DWH.setInputPin(0, IBUS1low.getOut(0)); 
        DWH.setPinLd(Oper1.ldDWH());
        
        DWL.setInputPin(0, IBUS1low.getOut(0));
        DWL.setPinLd(Oper1.ldDWL());
        
        for (int i = 0; i < 8; i++) {
            DW.setInputPin(i, DWL.getOut(i));
            DW.setInputPin(8 + i, DWH.getOut(i));
            DWHint.setInputPin(i, DWH.getOut(i));
            DWLint.setInputPin(i, DWL.getOut(i));
        }
        
        TSBDWout3.setInputPin(0, DW.getOut(0));
        TSBDWout3.setCtrl(Oper1.DWout3()); // neka ostane naziv DWout3, prepravio sam na slikama
        Bus1.addOnIBUS2(TSBDWout3.getOut(0)); /////////////// ja ne mogu da poverujem kakva gresku su mi uvalili :@@@@@@@@@@@@@@@@
        // neka se zove TSBDWout3, ali kacim ga na IBUS2
        
    }
    
    public static void gui() {
        GuiLine line; // Pomocna promenljiva
        gui = new GuiScheme("tmhm/tmhm/images/Bus1.png");
        
        ArrayList<ArrayList<Point>> sections;
        ArrayList<Point> points;
        
        

sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(619,5));
points.add(new Point(619,804));
sections.add(points);
line=new GuiLine(sections,Bus1.IBUS1());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(600,20));
points.add(new Point(600,642));
points.add(new Point(468,642));
points.add(new Point(468,804));
sections.add(points);
line=new GuiLine(sections,Bus1.IBUS2());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(581,35));
points.add(new Point(581,623));
points.add(new Point(318,623));
points.add(new Point(318,804));
sections.add(points);
line=new GuiLine(sections,Bus1.IBUS3());
gui.addLine(line);


sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(542,700));
points.add(new Point(542,694));
sections.add(points);
line=new GuiLine(sections,Oper1.MOST1_2());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(542,757));
points.add(new Point(542,750));
sections.add(points);
line=new GuiLine(sections,Oper1.MOST2_1());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(391,672));
points.add(new Point(391,666));
sections.add(points);
line=new GuiLine(sections,Oper1.MOST1_3());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(391,728));
points.add(new Point(391,722));
sections.add(points);
line=new GuiLine(sections,Oper1.MOST3_2());
gui.addLine(line);


sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(531,689));
points.add(new Point(468,689));
sections.add(points);
line=new GuiLine(sections,TSBMOST1_2.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(468,746));
points.add(new Point(530,746));
sections.add(points);
line=new GuiLine(sections,Bus1.IBUS2());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(552,746));
points.add(new Point(619,746));
sections.add(points);
line=new GuiLine(sections,TSBMOST2_1.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(553,689));
points.add(new Point(619,689));
sections.add(points);
line=new GuiLine(sections,Bus1.IBUS1());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(401,718));
points.add(new Point(468,718));
sections.add(points);
line=new GuiLine(sections,TSBMOST3_2.getOut(0));
gui.addLine(line);
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(379,718));
		points.add(new Point(318,718));
		sections.add(points);
		line=new GuiLine(sections,Bus1.IBUS3());
		gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(380,661));
points.add(new Point(318,661));
sections.add(points);
line=new GuiLine(sections,TSBMOST1_3.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(402,661));
points.add(new Point(619,661));
sections.add(points);
line=new GuiLine(sections,Bus1.IBUS1());
gui.addLine(line);

        

sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(126,180));
points.add(new Point(133,180));
sections.add(points);
line=new GuiLine(sections,Oper1.ldMAR());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(126,199));
points.add(new Point(133,199));
sections.add(points);
line=new GuiLine(sections,Oper1.incMAR());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(284,189));
points.add(new Point(291,189));
sections.add(points);
line=new GuiLine(sections,LogicalComponent.getCPUCLK());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(208,208));
points.add(new Point(208,312));
sections.add(points);
line=new GuiLine(sections,MAR.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(197,323));
points.add(new Point(204,323));
sections.add(points);
line=new GuiLine(sections,Oper1.eMAR());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(208,334));
points.add(new Point(208,351));
sections.add(points);
line=new GuiLine(sections,TSBeMAR.getOut(0));
gui.addLine(line);

        
        

sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(457,85));
points.add(new Point(457,104));
sections.add(points);
line=new GuiLine(sections,Bus1.DBUS());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(581,80));
points.add(new Point(476,80));
points.add(new Point(476,104));
sections.add(points);
line=new GuiLine(sections,Bus1.IBUS3());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(495,123));
points.add(new Point(501,123));
sections.add(points);
line=new GuiLine(sections,Oper1.mxMDR());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(466,142));
points.add(new Point(466,170));
sections.add(points);
line=new GuiLine(sections,MX1.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(337,255));
points.add(new Point(344,255));
sections.add(points);
line=new GuiLine(sections,Bus1.NOTFCBUS());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(371,255));
points.add(new Point(378,255));
points.add(new Point(378,227));
points.add(new Point(316,227));
points.add(new Point(316,201));
points.add(new Point(323,201));
sections.add(points);
line=new GuiLine(sections,Bus1.NOT1.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(152,416));
points.add(new Point(152,409));
sections.add(points);
line=new GuiLine(sections,Oper1.rdCPU());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(346,195));
points.add(new Point(363,195));
points.add(new Point(353,195));
points.add(new Point(353,202));
sections.add(points);
line=new GuiLine(sections,AND1.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(353,152));
points.add(new Point(353,184));
points.add(new Point(363,184));
sections.add(points);
line=new GuiLine(sections,Oper1.ldMDR());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(383,189));
points.add(new Point(391,189));
sections.add(points);
line=new GuiLine(sections,OR1.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(542,189));
points.add(new Point(548,189));
sections.add(points);
line=new GuiLine(sections,LogicalComponent.getCPUCLK());
gui.addLine(line);

sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(316,152));
points.add(new Point(316,189));
points.add(new Point(323,189));
sections.add(points);
line=new GuiLine(sections,Oper1.rdCPU());
gui.addLine(line);

        

sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(466,208));
points.add(new Point(466,312));
sections.add(points);
line=new GuiLine(sections,MDR.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(466,255));
points.add(new Point(483,255));
sections.add(points);
line=new GuiLine(sections,MDR.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(494,260));
points.add(new Point(494,266));
sections.add(points);
line=new GuiLine(sections,Oper1.MDRout1());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(505,255));
points.add(new Point(619,255));
sections.add(points);
line=new GuiLine(sections,TSBMDRout1.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(455,323));
points.add(new Point(462,323));
sections.add(points);
line=new GuiLine(sections,Oper1.eMDR());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(466,334));
points.add(new Point(466,351));
sections.add(points);
line=new GuiLine(sections,TSBeMDR.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(130,404));
points.add(new Point(141,404));
sections.add(points);
line=new GuiLine(sections,new Pin(true));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(168,404));
points.add(new Point(174,404));
sections.add(points);
line=new GuiLine(sections, NOT2.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(250,404));
points.add(new Point(261,404));
sections.add(points);
line=new GuiLine(sections,new Pin(true));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(272,410));
points.add(new Point(272,415));
sections.add(points);
line=new GuiLine(sections,Oper1.wrCPU());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(288,404));
points.add(new Point(295,404));
sections.add(points);
line=new GuiLine(sections,NOT3.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(401,399));
points.add(new Point(412,399));
sections.add(points);
line=new GuiLine(sections,new Pin(false));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(401,410));
points.add(new Point(407,410));
sections.add(points);
line=new GuiLine(sections,Oper1.eMAR());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(434,404));
points.add(new Point(441,404));
sections.add(points);
line=new GuiLine(sections,AND2.getOut(0));
gui.addLine(line);

        

sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(619,468));
points.add(new Point(252,468));
points.add(new Point(252,487));
sections.add(points);
line=new GuiLine(sections,IBUS1low.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(466,468));
points.add(new Point(466,487));
sections.add(points);
line=new GuiLine(sections,IBUS1low.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(169,497));
points.add(new Point(177,497));
sections.add(points);
line=new GuiLine(sections,LogicalComponent.getCPUCLK());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(384,497));
points.add(new Point(391,497));
sections.add(points);
line=new GuiLine(sections,LogicalComponent.getCPUCLK());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(169,516));
points.add(new Point(177,516));
sections.add(points);
line=new GuiLine(sections,Oper1.ldDWH());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(252,525));
points.add(new Point(252,543));
sections.add(points);
line=new GuiLine(sections,DWHint.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(384,516));
points.add(new Point(391,516));
sections.add(points);
line=new GuiLine(sections,Oper1.ldDWL());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(466,525));
points.add(new Point(466,544));
sections.add(points);
line=new GuiLine(sections,DWLint.getOut(0));
gui.addLine(line);

        
        

sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(382,570));
points.add(new Point(407,570));
sections.add(points);
line=new GuiLine(sections,DWHint.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(382,585));
points.add(new Point(407,585));
sections.add(points);
line=new GuiLine(sections,DWLint.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(445,578));
points.add(new Point(483,578));
sections.add(points);
line=new GuiLine(sections,DW.getOut(0));
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(494,589));
points.add(new Point(494,583));
sections.add(points);
line=new GuiLine(sections,Oper1.DWout3());
gui.addLine(line);
sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(505,578));
points.add(new Point(600,578));
sections.add(points);
line=new GuiLine(sections,TSBDWout3.getOut(0));
gui.addLine(line);


sections=new ArrayList<ArrayList<Point>>();
points=new ArrayList<Point>();
points.add(new Point(208,170));
points.add(new Point(208,67));
points.add(new Point(600,67));
sections.add(points);
line=new GuiLine(sections,Bus1.IBUS2());
gui.addLine(line);


        //  odradi LABELE:
        gui.addLabel(new GuiLabel(622, 28, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(602, 46, Bus1.IBUS2()));
        gui.addLabel(new GuiLabel(584, 64, Bus1.IBUS3()));
        
        gui.addLabel(new GuiLabel(212, 145, Bus1.IBUS2()));
        gui.addLabel(new GuiLabel(456, 463, IBUS1low.getOut(0)));
        gui.addLabel(new GuiLabel(255, 463, IBUS1low.getOut(0)));
        
       gui.addLabel(new GuiLabel(478, 705, TSBMOST1_2.getOut(0)));
        gui.addLabel(new GuiLabel(580, 761, TSBMOST2_1.getOut(0)));
        gui.addLabel(new GuiLabel(330, 677, TSBMOST1_3.getOut(0)));
        gui.addLabel(new GuiLabel(431, 734, TSBMOST3_2.getOut(0)));

        gui.addLabel(new GuiLabel(221, 248, MAR.getOut(0)));
        
        gui.addLabel(new GuiLabel(471, 362, TSBeMDR.getOut(0)));
        gui.addLabel(new GuiLabel(195, 362, TSBeMAR.getOut(0)));
        gui.addLabel(new GuiLabel(449, 82, DBUS.getOut(0)));
        gui.addLabel(new GuiLabel(475, 157, MX1.getOut(0)));
        gui.addLabel(new GuiLabel(443, 237, MDR.getOut(0)));
        gui.addLabel(new GuiLabel(535, 271, TSBMDRout1.getOut(0)));
        gui.addLabel(new GuiLabel(244, 555, DWHint.getOut(0)));
        gui.addLabel(new GuiLabel(461, 555, DWLint.getOut(0)));
        gui.addLabel(new GuiLabel(452, 592, DW.getOut(0)));
        gui.addLabel(new GuiLabel(532, 574, TSBDWout3.getOut(0)));
        
        
        
        
    }
    
    public static void addOnIBUS1(Pin pin) {
        IBUS1.setInputPin(ibus1i++, pin);
    }
    
    public static void addOnIBUS2(Pin pin) {
        IBUS2.setInputPin(ibus2i++, pin);
    }
    
    public static void addOnIBUS3(Pin pin) {
        IBUS3.setInputPin(ibus3i++, pin);
    }
    
    public static void addOnDBUS(Pin pin) {
        DBUS.setInputPin(dbusi++, pin);
    }
    
    public static void addOnABUS(Pin pin) {
        ABUS.setInputPin(abusi++, pin);
    }
    
    public static void addOnNOTRDBUS(Pin pin) {
        NOTRDBUS.setInputPin(rdbusi++, pin);
    }
    
    public static void addOnNOTWRBUS(Pin pin) {
        NOTWRBUS.setInputPin(wrbusi++, pin);
    }
    
    public static void addOnNOTFCBUS(Pin pin) {
        NOTFCBUS.setInputPin(fcbusi++, pin);
    }
    
    public static Pin IBUS1() {
        return IBUS1.getOut(0);
    }
    
    public static Pin IBUS2() {
        return IBUS2.getOut(0);
    }
    
    public static Pin IBUS3() {
        return IBUS3.getOut(0);
    }
    
    public static Pin ABUS() {
        return ABUS.getOut(0);
    }
    
    public static Pin DBUS() {
        return DBUS.getOut(0);
    }
    
    public static Pin NOTRDBUS() {
        return NOTRDBUS.getOut(0);
    }
    
    public static Pin NOTWRBUS() {
        return NOTWRBUS.getOut(0);
    }
    
    public static Pin NOTFCBUS() {
        return NOTFCBUS.getOut(0);
    }
    
    public static Pin MDR() {
        return MDR.getOut(0);
    }
    
    public static Pin MAR() {
        return MAR.getOut(0);
    }
    
    public static Pin MX1() {
        return MX1.getOut(0);
    }
    
    public static Pin TSBMOST1_2out() {
        return TSBMOST1_2.getOut(0);
    }
    
    public static Pin TSBMOST2_1out() {
        return TSBMOST2_1.getOut(0);
    }
    
    public static Pin TSBMDRoutToIBUS() {
        return TSBMDRout1.getOut(0);
    }
    
    public static Pin TSBeMDRout() {
        return TSBeMDR.getOut(0);
    }
    
    public static Pin TSBMARout() {
        return TSBeMAR.getOut(0);
    }
    
    public static Pin fcCPU() {
        return NOT1.getOut(0);
    }
    
    public static Pin hack() {
        return AND2.getOut(0);
    }
    
    public static REG RegMAR() {
        return MAR;
    }
    
    public static REG RegMDR() {
        return MDR;
    }
    
    public static REG RegDWH() {
        return DWH;
    }
    
    public static REG RegDWL() {
        return DWL;
    }
}
